package ui;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

// TODO: all the text fields create a new numeric key adapter, perhaps create just one and get all the text fields to use it?
public class NumericKeyAdapter extends KeyAdapter
{
	public void keyTyped(KeyEvent e)
	{
		// eat any characters that are not digits (and some special characters like backspace)
		char c = e.getKeyChar();
        if (!((c==KeyEvent.VK_BACK_SPACE) || (c==KeyEvent.VK_DELETE) ||  (c== KeyEvent.VK_ENTER)  || (c == KeyEvent.VK_TAB) ||
        		(c==KeyEvent.VK_DECIMAL) || (c==KeyEvent.VK_PERIOD) || (c==KeyEvent.VK_MINUS) || (Character.isDigit(c)))) e.consume();
	}
}
